Return to the menu   Select another DES Module

Demonstrates how to report errors for entering an unselectable date

The DateTextBox can report errors for entering an unselectable date. The DateTextBox is matched up with two controls, the UnselectableDatesValidator and the SpecialDates control. The SpecialDates control hosts the dates that are unselectable.


Controls

In this example, Sunday and Wednesday are not valid. The PeterBlum.DES.Web.WebControls.SpecialDayOfWeek objects provide a string to show in the validator's error message. That string is defined in the Label property and shown by using the {DATELABEL} token in the UnselectableDatesValidator.ErrorMessage property. If no label is defined, it falls back to the value in UnselectableDatesValidator.NoLabelErrorMessage.

Enter dates in the textbox. When you enter a date that is Sunday or Wednesday, an error is shown. Also note that the DateTextBox's calendar follows the rules of the SpecialDates control.

...



Source Code (C#)

<script runat="server">
protected void Button1_OnClick(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save the data } }
</script> <p> In this example, Sunday and Wednesday are not valid. The <span class="ControlClass">PeterBlum.DES.Web.WebControls.SpecialDayOfWeek</span> objects provide a string to show in the validator's error message. That string is defined in the Label property and shown by using the {DATELABEL} token in the <span class="PropertyName">UnselectableDatesValidator.ErrorMessage</span> property. If no label is defined, it falls back to the value in <span class="PropertyName">UnselectableDatesValidator.NoLabelErrorMessage</span>.</p> <p> Enter dates in the textbox. When you enter a date that is Sunday or Wednesday, an error is shown. Also note that the DateTextBox's calendar follows the rules of the SpecialDates control. </p> <des:DateTextBox ID="DateTextBox1" runat="server" SpecialDatesControlID="SpecialDates1" Hint="Closed on Sundays and Wednesday" /> <des:UnselectableDatesValidator ID="UnselectableDatesValidator1" runat="server" ControlIDToEvaluate="DateTextBox1" ErrorMessage="That date cannot be used. We are closed on {DATELABEL}." NoLabelErrorMessage="that date" /> <des:SpecialDates ID="SpecialDates1" runat="server" UnknownDatesAreUnselectable="False"> <des:SpecialDayOfWeek Label="Sundays" Selectable="Unselectable" DayOfWeek="Sunday"></des:SpecialDayOfWeek> <des:SpecialDayOfWeek Label="Wednesdays" Selectable="Unselectable" DayOfWeek="Wednesday"></des:SpecialDayOfWeek> </des:SpecialDates> <br/> <br/> <des:Button ID="Button1" runat="server" Text="Client Side" OnClick="Button1_OnClick" />

Return to the menu   Select another DES Module